<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
        window.onload = function() {
            var uu = document.getElementById('uu');
            var uli = uu.getElementsByTagName('li');
            var btn = document.getElementById('btn');
            btn.onclick = function() {
                for(var i = 0;i < uli.length;i++){
                    uli[i].style.backgroundColor = i%2==0? 'red':'green';
                }
            }

        }
    </script>
</head>
<body>
    <input type="button" value="变色"  id = "btn">
    <ul id = "uu">
        <li>perspective</li>
        <li>perspective</li>
        <li>perspective</li>
        <li>perspective</li>
        <li>perspective</li>
        <li>perspective</li>
        <li>perspective</li>
        <li>perspective</li>
    </ul>
</body>
</html>